package top.mcwebsite.playandroid.business.home.impl.ui

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import top.mcwebsite.playandroid.strings.Str

@Composable
fun Search(
    modifier: Modifier = Modifier
) {
    BoxWithConstraints(
        modifier = Modifier
            .border(
                border = BorderStroke(width = 1.dp, color = MaterialTheme.colorScheme.onBackground),
                shape = RoundedCornerShape(25.dp)
            ).clip(
                shape = RoundedCornerShape(size = 25.dp)
            ).then(modifier)
    ) {
        Row(
            modifier = Modifier.align(Alignment.CenterStart)
        ) {
            Icon(
                Icons.Default.Search,
                contentDescription = stringResource(id = Str.search),
                tint = LocalContentColor.current.copy(alpha = 0.5f),
                modifier = Modifier.align(Alignment.CenterVertically)
                    .padding(start = 10.dp)
                    .size(this@BoxWithConstraints.minHeight / 3 * 2)
            )
            Text(
                text = stringResource(id = Str.search_tips),
                color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.3f),
                style = MaterialTheme.typography.labelMedium,
                modifier = Modifier
                    .align(Alignment.CenterVertically)
            )
        }
    }
}